The string is 15 characters long
An object consists of both variables (state information) and
methods
referenceToAnObject.memberOfObject
For example, to invoke the length()
method of the object
named str1
do this:
str1.length();
To store the value computed by the length method in a variable, do this:
len = str1.length();
Method names have ()
at their end.
Often there is additional information inside the ()
,
but they are required even if they contain nothing.
(Thought Question:) Is it possible for a program to have several objects all of the same class?